//import com.zl.User;
import com.zl.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class APP {
    public static void main(String[] args) {
        //1.获取Spring上下文对象
        ApplicationContext context=new ClassPathXmlApplicationContext("spring-config.xml");
        //2.1.从中获取bean对象
//        User user1= (User) context.getBean("user1");
//        User user2= (User) context.getBean("user2");

        //2.2  根据Class参数获取bean对象。当配置文件中一个类被同时注册时，会报错。[根据类型获取类对象]
        //User user=context.getBean(User.class);
        //2.3 根据String(bean id)+class获取class对象。
        User user1=context.getBean("user1",User.class);
        user1.sayHello();
       // user2.sayHello();
    }
}
